﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GraphicLib
{
    public class VarianceComparer
    {
        /// <summary>
        /// 比较样品与产品方差的方法，返回是否好品
        /// </summary>
        /// <param name="sampleVariance">样品方差</param>
        /// <param name="productVariance">产品方差</param>
        /// <returns></returns>
        public static bool CompareVariance(double sampleVariance, double productVariance) 
        {
            if (sampleVariance == 0)
            {
                sampleVariance = 0.00001;
            }
            return ((sampleVariance >= productVariance * ProductCheck.VARIANCE_TOLERANCE) || (Math.Abs(sampleVariance) < 10 && Math.Abs(productVariance) < 10)) ? true : false;
            //return Math.Abs(1-productVariance / sampleVariance) <= Math.Abs(1-ProductCheck.VARIANCE_TOLERANCE) || (Math.Abs(sampleVariance) < 10 && Math.Abs(productVariance) < 10) ? true : false;
        }
    }
}
